package Part2_java.util.Map.Hashtable.Properties;

import org.junit.Test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

/**
 * ClassName: PropertiesTest
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.04.15 23:03
 */
public class PropertiesTest {
    @Test
    public void test1() throws IOException {
        File file = new File("info.properties");
        //调文件的绝对路径
        //System.out.println(file.getAbsoluteFile());
        FileInputStream fis = new FileInputStream(file);//需要throws FileNotFoundException

        Properties pros = new Properties();
        //IO流
        //加载流中文件的数据
        pros.load(fis);//需要throws IOException

        String name = pros.getProperty("name");
        String pasW = pros.getProperty("password");

        System.out.println(name+":"+pasW);

        fis.close();
    }
}
